<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t " id="signupForm" method="post"
			enctype="multipart/form-data">
			<input type="hidden" id="telentsId" name="telentsId" value="${telentsId }"/> <!-- 简历id -->
			<input type="hidden" name="companyId" value="${companyId }"/>
			<input type="hidden" name="recommendId"  id="recommendId" value="${recommendId }"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">沟通事项：</label>
				<div class="col-sm-8">
					<select class="form-control" name="classid" id="classid">
						<c:forEach items="${fns:getDictList('demand_status')}"
							var="temp1">
							<option value="${temp1.value }">${temp1.valueName }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<c:if test="${empty demandId}">
			
			</c:if>
			<c:if test="${ not empty demandId}">
			<input type="hidden" name="projectId" value="${demandId }"/>
			</c:if>
			<div class="form-group">
				<label class="col-sm-3 control-label">沟通时间：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control datetime" id="communicationTime" name="communicationTime" placeholder="请选择时间" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">沟通方式：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="methods" name="methods" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">沟通目的：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="purpose" name="purpose" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">意向性：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="intentionality" name="intentionality" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">沟通详情：</label>
				<div class="col-sm-8">
					<textarea rows="3" cols="3" class="form-control" id="details" name="details" placeholder="请填写沟通详请"></textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">下次沟通：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control datetime" id="nextTime" name="nextTime" placeholder="请选择时间" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label"> 备注 ：</label>
				<div class="col-sm-8">
					<textarea rows="3" cols="3" class="form-control" id="remark" name="remark"></textarea>
				</div>
			</div>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-12">
					<button class="btn btn-primary" type="button" id="sub">提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
    $(function () {
    	$('#communicationTime').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
	        autoclose: true,
	        todayBtn: true,
	        startView: 'day',
	        minView:'day',
	        maxView:'decade',
	        language:  'zh-CN',
	        initialDate : new Date()
	  });
      $('#communicationTime').datetimepicker('setDate',(new Date()));//赋值，当前日期
      $('#nextTime').datetimepicker({
          format: 'yyyy-mm-dd hh:ii:ss',
	        autoclose: true,
	        todayBtn: true,
	        startView: 'day',
	        minView:'day',
	        maxView:'decade',
	        language:  'zh-CN',
	        startDate: new Date()
	  });
      $('#nextTime').datetimepicker('setDate',(new Date()));//赋值，当前日期
        $("#sub").click(function () {
        	//批量验证表单非空
			//调用方式
        	var arr=new Array(
        	  //new Array('type','人才分类未填写!'),
        	  new Array('classid','事项分类未填写!'),
        	  new Array('details','沟通详情未填写!'),
        	  //new Array('STATUS','状态未填写!'),
        	  new Array('communicationTime','沟通时间未填写!'),
        	  new Array('nextTime','下次沟通未填写!')
        	  //new Array('telentsId','所属简历未填写!'),
        	  //new Array('remark',' 备注 未填写!')
        	);
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/demandCommunicate/add',
					type : 'post',
					dataType : "json",
					success : function(data) {
						if (data.code == 200) {
							swal({
								title : data.message,
								type : "success",
								showCancelButton : false,
								confirmButtonText : "确定",
								animation : "slide-from-bottom",
								closeOnConfirm : true
							}, function() {
								top.Dialog.close();
							});
						} else {
							swal("错误", data.message, "error");
						}
					}
				});

			});
      var recommendId=$("#recommendId").val();
      $("#classid").change(function(){
    	  var classid = $("#classid").val();
    	  //背调4
    	  if(classid==4){
    		  openyem("添加背景调查", "<%=contextPath%>/demandInvestigation/addView?recommendId="+recommendId, 800, 750);
    	  }
    	  //发offer5
    	  if(classid==5){
    		  openyem("添加offer记录", "<%=contextPath%>/demandOfferRecord/addView?recommendId="+recommendId, 500, 550);
    	  }
      });
		});
	</script>
</body>
</html>